﻿
// RTOC-Data-InterfaceView.cpp: CRTOCDataInterfaceView 类的实现
//

#include "pch.h"
#include "framework.h"
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
// ATL 项目中进行定义，并允许与该项目共享文档代码。
#ifndef SHARED_HANDLERS
#include "RTOC-Data-Interface.h"
#endif

#include "RTOC-Data-InterfaceDoc.h"
#include "RTOC-Data-InterfaceView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CRTOCDataInterfaceView

IMPLEMENT_DYNCREATE(CRTOCDataInterfaceView, CFormView)

BEGIN_MESSAGE_MAP(CRTOCDataInterfaceView, CFormView)
	ON_WM_CONTEXTMENU()
	ON_WM_RBUTTONUP()
	ON_WM_PAINT()
	ON_WM_SIZE()
	ON_WM_CTLCOLOR()
	ON_WM_TIMER()
	ON_NOTIFY(NM_CLICK, IDC_LIST1, &CRTOCDataInterfaceView::OnNMClickList1)
	ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST1, &CRTOCDataInterfaceView::OnNMCustomdrawList1)
	ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CRTOCDataInterfaceView::OnNMDblclkList1)
END_MESSAGE_MAP()

// CRTOCDataInterfaceView 构造/析构

CRTOCDataInterfaceView::CRTOCDataInterfaceView()
	: CFormView(CRTOCDataInterfaceView::IDD)
{
	// TODO: 在此处添加构造代码
	m_nCurSelRow = -1;
	m_nTickCount = 0;
	m_strOldErrorMsg = _T("");
}

CRTOCDataInterfaceView::~CRTOCDataInterfaceView()
{
}

void CRTOCDataInterfaceView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_ctlList);
	//DDX_Control(pDX, IDC_BTTLM, m_btTLM);
	//DDX_Control(pDX, IDC_BTMASTER, m_btMASTER);
	//DDX_Control(pDX, IDC_BTYQH, m_btYQH);
	//DDX_Control(pDX, IDC_BTREDIS, m_btREDIS);
	//DDX_Control(pDX, IDC_BTKD, m_btKD);
}

BOOL CRTOCDataInterfaceView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: 在此处通过修改
	//  CREATESTRUCT cs 来修改窗口类或样式

	return CFormView::PreCreateWindow(cs);
}

void CRTOCDataInterfaceView::OnRButtonUp(UINT /* nFlags */, CPoint point)
{
	ClientToScreen(&point);
	OnContextMenu(this, point);
}

void CRTOCDataInterfaceView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
{
#ifndef SHARED_HANDLERS
	theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
#endif
}


// CRTOCDataInterfaceView 诊断

#ifdef _DEBUG
void CRTOCDataInterfaceView::AssertValid() const
{
	CFormView::AssertValid();
}

void CRTOCDataInterfaceView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CRTOCDataInterfaceDoc* CRTOCDataInterfaceView::GetDocument() const // 非调试版本是内联的
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CRTOCDataInterfaceDoc)));
	return (CRTOCDataInterfaceDoc*)m_pDocument;
}
#endif //_DEBUG


void CRTOCDataInterfaceView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	m_ctlList.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
	m_ctlList.InsertColumn(0, _T("序号"), LVCFMT_LEFT, 40);
	m_ctlList.InsertColumn(1, _T("井名"), LVCFMT_LEFT, 80);
	m_ctlList.InsertColumn(2, _T("井深"), LVCFMT_LEFT, 80);
	m_ctlList.InsertColumn(3, _T("更新时间"), LVCFMT_LEFT, 150);
	m_ctlList.InsertColumn(4, _T("通信状态"), LVCFMT_LEFT, 100);
	m_ctlList.InsertColumn(5, _T("中心库"), LVCFMT_LEFT, 120);
	m_ctlList.InsertColumn(6, _T("一体化库"), LVCFMT_LEFT, 120);
	m_ctlList.InsertColumn(7, _T("KD库"), LVCFMT_LEFT, 120);
	m_ctlList.InsertColumn(8, _T("一体化URL"), LVCFMT_LEFT, 120);


	m_btTLM.SubclassDlgItem(IDC_BTTLM, this);
	m_btMASTER.SubclassDlgItem(IDC_BTMASTER, this);
	m_btYQH.SubclassDlgItem(IDC_BTYQH, this);
	m_btREDIS.SubclassDlgItem(IDC_BTREDIS, this);
	m_btKD.SubclassDlgItem(IDC_BTKD, this);
	m_nTimer = SetTimer(9002, 1000, NULL);

	FillList(TRUE);
}

// CRTOCDataInterfaceView 消息处理程序
void CRTOCDataInterfaceView::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	m_nCurSelRow = m_ctlList.GetSelectionMark();
	int row = pNMItemActivate->iItem;//行
	int col = pNMItemActivate->iSubItem;//列

	*pResult = 0;
}

void CRTOCDataInterfaceView::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	if (gl.m_bRunSync)
	{
		AfxMessageBox(_T("正在同步，不可更改状态！\r\n请先停止同步，再进行状态更改。"), MB_ICONINFORMATION);
		return;
	}

	m_nCurSelRow = m_ctlList.GetSelectionMark();
	int row = pNMItemActivate->iItem;//行
	int col = pNMItemActivate->iSubItem;//列
	if (row >= 0)
	{
		if (col == 5)
			gl.ChangeSyncStatus(1, row);
		if (col == 6)
			gl.ChangeSyncStatus(0, row);
		if (col == 7)
			gl.ChangeSyncStatus(2, row);
		if (col == 8)
			gl.ChangeSyncStatus(3, row);
		CString strTemp;
		strTemp.Format(_T("row=%d,col=%d"), row, col);
		//AfxMessageBox(strTemp);
	}

	*pResult = 0;
}

void CRTOCDataInterfaceView::OnPaint()
{
	CPaintDC dc(this); // device context for painting
					   // TODO: 在此处添加消息处理程序代码
					   // 不为绘图消息调用 CFormView::OnPaint()
	dc.SetBkMode(TRANSPARENT);

	if (!::IsWindow(GetDlgItem(IDC_DATAAREA)->m_hWnd)) return;

	CRect rt;
	GetDlgItem(IDC_DATAAREA)->GetWindowRect(&rt);
	ScreenToClient(&rt);

	try
	{
		CBitmap*Oldmap;
		CBitmap cBitmap;
		CDC memDC;
		cBitmap.CreateCompatibleBitmap(&dc, rt.Width(), rt.Height());
		memDC.CreateCompatibleDC(&dc);
		Oldmap = memDC.SelectObject(&cBitmap);
		CDC* pMemDC = &memDC;
		OnPrepareDC(pMemDC);

		CRect rtDraw = CRect(CPoint(0, 0), CSize(rt.Width(), rt.Height()));
		DrawFrame(pMemDC, rtDraw);

		CRect rtUpdata = rt;
		dc.BitBlt(rtUpdata.left, rtUpdata.top,
			rtUpdata.Width(), rtUpdata.Height(), pMemDC,
			rtDraw.left, rtDraw.top, SRCCOPY);
		memDC.SelectObject(Oldmap);
		memDC.DeleteDC();
		cBitmap.DeleteObject();
	}
	catch (...)
	{

	}
}

void CRTOCDataInterfaceView::DrawInBorder(CDC* pDC, CRect rt, COLORREF tc, COLORREF bc)
{
	CPen pent, penb;
	pent.CreatePen(PS_SOLID, 1, tc);
	penb.CreatePen(PS_SOLID, 1, bc);
	CPen* oldPen = pDC->SelectObject(&pent);
	pDC->MoveTo(rt.right - 1, rt.top);
	pDC->LineTo(rt.left, rt.top);
	pDC->LineTo(rt.left, rt.bottom);

	pDC->MoveTo(rt.right - 2, rt.top + 1);
	pDC->LineTo(rt.left + 1, rt.top + 1);
	pDC->LineTo(rt.left + 1, rt.bottom - 1);

	pDC->SelectObject(&penb);
	pDC->MoveTo(rt.right, rt.top + 1);
	pDC->LineTo(rt.right, rt.bottom);
	pDC->LineTo(rt.left, rt.bottom);

	pDC->MoveTo(rt.right - 1, rt.top + 2);
	pDC->LineTo(rt.right - 1, rt.bottom - 1);
	pDC->LineTo(rt.left + 1, rt.bottom - 1);
	rt.DeflateRect(2, 2);
	pDC->FillSolidRect(rt, RGB(212, 212, 212));
	pDC->SelectObject(oldPen);
}

void BxGradientFill1(CDC* pDC, CRect rt, COLORREF clrFillBackColor1, COLORREF clrFillBackColor2, int nFillStyle)
{
	int colorR, colorG, colorB;
	colorR = GetRValue(clrFillBackColor1); colorR = colorR << 8;
	colorG = GetGValue(clrFillBackColor1); colorG = colorG << 8;
	colorB = GetBValue(clrFillBackColor1); colorB = colorB << 8;
	int colorR1, colorG1, colorB1;
	colorR1 = GetRValue(clrFillBackColor2); colorR1 = colorR1 << 8;
	colorG1 = GetGValue(clrFillBackColor2); colorG1 = colorG1 << 8;
	colorB1 = GetBValue(clrFillBackColor2); colorB1 = colorB1 << 8;

	TRIVERTEX vert[4]; GRADIENT_TRIANGLE gTRi[2];
	if (nFillStyle == 0 || nFillStyle == 1 || nFillStyle == 2)
	{
		vert[0].x = rt.left;
		vert[0].y = rt.top;
		vert[0].Red = colorR;
		vert[0].Green = colorG;
		vert[0].Blue = colorB;
		vert[0].Alpha = 0x0000;

		vert[1].x = rt.right;
		vert[1].y = rt.top;
		vert[1].Red = (colorR + colorR1) / 2;
		vert[1].Green = (colorG + colorG1) / 2;
		vert[1].Blue = (colorB + colorB1) / 2;
		vert[1].Alpha = 0x0000;

		vert[2].x = rt.right;
		vert[2].y = rt.bottom;
		vert[2].Red = colorR1;
		vert[2].Green = colorG1;
		vert[2].Blue = colorB1;
		vert[2].Alpha = 0x0000;

		vert[3].x = rt.left;
		vert[3].y = rt.bottom;
		vert[3].Red = (colorR + colorR1) / 2;
		vert[3].Green = (colorG + colorG1) / 2;
		vert[3].Blue = (colorB + colorB1) / 2;
		vert[3].Alpha = 0x0000;
	}
	else
	{
		vert[0].x = rt.left;
		vert[0].y = rt.top;
		vert[0].Red = (colorR + colorR1) / 2;
		vert[0].Green = (colorG + colorG1) / 2;
		vert[0].Blue = (colorB + colorB1) / 2;
		vert[0].Alpha = 0x0000;

		vert[1].x = rt.right;
		vert[1].y = rt.top;
		vert[1].Red = colorR1;
		vert[1].Green = colorG1;
		vert[1].Blue = colorB1;
		vert[1].Alpha = 0x0000;

		vert[2].x = rt.right;
		vert[2].y = rt.bottom;
		vert[2].Red = (colorR + colorR1) / 2;
		vert[2].Green = (colorG + colorG1) / 2;
		vert[2].Blue = (colorB + colorB1) / 2;
		vert[2].Alpha = 0x0000;

		vert[3].x = rt.left;
		vert[3].y = rt.bottom;
		vert[3].Red = colorR;
		vert[3].Green = colorG;
		vert[3].Blue = colorB;
		vert[3].Alpha = 0x0000;
	}

	gTRi[0].Vertex1 = 0;
	gTRi[0].Vertex2 = 1;
	gTRi[0].Vertex3 = 2;
	gTRi[1].Vertex1 = 0;
	gTRi[1].Vertex2 = 2;
	gTRi[1].Vertex3 = 3;
	switch (nFillStyle)
	{
	case 0:
		GradientFill(pDC->m_hDC, vert, 4, &gTRi, 2, GRADIENT_FILL_RECT_H);
		break;
	case 1:
		GradientFill(pDC->m_hDC, vert, 4, &gTRi, 2, GRADIENT_FILL_RECT_V);
		break;
	case 2:
	case 3:
		GradientFill(pDC->m_hDC, vert, 4, &gTRi, 2, GRADIENT_FILL_TRIANGLE);
		break;
	}
}
#define MAXROWS 15
void CRTOCDataInterfaceView::DrawFrame(CDC *pDC, CRect rtArea)
{
	CString strTemp;
	CPen pen(0, 1, RGB(240, 240, 240));
	CPen*   pOldPen = pDC->SelectObject(&pen);
	LOGFONT lf;								//LOGFONT结构中的变量用于定义字体的各种特性
	memset(&lf, 0, sizeof(lf));
	lf.lfCharSet = CHINESEBIG5_CHARSET;		//设置字符集
	lf.lfHeight = 13;
	wcscpy(lf.lfFaceName, _T("宋体"));		//设置字体名称 MingLiu为MS提供的BIG5字体
	CFont font;
	font.CreateFontIndirect(&lf);			//创建字体
	CFont* pF = (CFont*)pDC->SelectObject(&font);	//保存当前字体

	pDC->SetBkMode(TRANSPARENT);
	double dHeight = rtArea.Height()*1.0 / MAXROWS;
	for (int k = 0; k < 4; k++)
	{
		for (int i = 0; i < MAXROWS; i++)
		{
			int nLeft = rtArea.left + rtArea.Width()*k / 4;
			int nTop = rtArea.top + dHeight * i;
			CRect rt = CRect(CPoint(nLeft, nTop), CSize(rtArea.Width() / 4, (int)dHeight));
			rt.top = rt.top + 1;
			rt.bottom = rt.bottom - 1;
			rt.left = rt.left + 1;
			rt.right = rt.right - 1;
			DrawInBorder(pDC, rt);
			BxGradientFill1(pDC, rt, RGB(255, 222, 189), RGB(220, 255, 200), 0);
			rt.left = rt.left + 2;
			rt.right = rt.right - 2;
			int nID =  k * MAXROWS + i;
			pDC->SetTextColor(RGB(0, 0, 255));
			pDC->DrawTextW(gl.pi.metricName[nID], &rt, DT_LEFT | DT_VCENTER | DT_SINGLELINE);
			if (gl.pi.metricName[nID] == _T("")) continue;
			strTemp = _T("");
			strTemp.Format(_T("%.2f"), sw.dParVal[nID]);
			rt.right = rt.right - 35;
			pDC->SetTextColor(RGB(64, 0, 64));
			pDC->DrawTextW(strTemp, &rt, DT_RIGHT | DT_VCENTER | DT_SINGLELINE);
			pDC->SetTextColor(RGB(0, 0, 0));
		}
	}
	pDC->SelectObject(&pF);
	pF->DeleteObject();
}


void CRTOCDataInterfaceView::OnSize(UINT nType, int cx, int cy)
{
	CFormView::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	if (GetDlgItem(IDC_DATAAREA)==NULL) return;

	CRect rt;
	GetDlgItem(IDC_DATAAREA)->GetWindowRect(rt);
	if (rt.Height() % MAXROWS != 0)
	{
		int nHeight = rt.Height() / MAXROWS * MAXROWS;
		rt.bottom = rt.top + nHeight;
		ScreenToClient(rt);
		GetDlgItem(IDC_DATAAREA)->MoveWindow(rt);
	}
}


HBRUSH CRTOCDataInterfaceView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);

	// TODO:  在此更改 DC 的任何特性
	int nID = pWnd->GetDlgCtrlID();
	if (nCtlColor == CTLCOLOR_EDIT)
	{
		if (nID == IDC_SYSTIME2 || nID == IDC_SYSTIME1)
		{
			COLORREF clr = TXTFORCOLOR;
			pDC->SetTextColor(clr);		//设置红色的文本
			clr = TXTBKCOLOR;
			pDC->SetBkColor(clr);		//设置背景
			return gl.m_brMine;			//返回的是背景色对应的刷子句柄 
		}
	}
	// TODO:  如果默认的不是所需画笔，则返回另一个画笔
	return hbr;
}


void CRTOCDataInterfaceView::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值
	if (m_nTimer == nIDEvent)
	{
		CTime tt = CTime::GetCurrentTime();
		CString strTemp;
		GetDlgItem(IDC_SYSTIME1)->SetWindowText(tt.Format(_T("%Y-%m-%d %H:%M:%S")));
		strTemp.Format(_T("%d"), tt.GetTime());
		GetDlgItem(IDC_SYSTIME2)->SetWindowText(strTemp);

		if (m_nTickCount % 5 == 0)
		{
			try
			{
				if (gl.m_bResetList)
				{
					gl.m_bResetList = FALSE;
					FillList(TRUE);
				}
				else
					FillList(FALSE);
				if (m_nCurSelRow >= 0 && m_nCurSelRow < gl.tlm.m_aWells.GetCount())
					sw = gl.tlm.m_aWells.GetAt(m_nCurSelRow);

				CRect rt;
				GetDlgItem(IDC_DATAAREA)->GetWindowRect(rt);
				ScreenToClient(rt);
				InvalidateRect(rt);

				if (m_strOldErrorMsg != gl.m_strErrorMsg)
				{
					GetDlgItem(IDC_ERRORMSG)->SetWindowText(tt.Format(_T("%m-%d %H:%M:%S "))+gl.m_strErrorMsg);
					m_strOldErrorMsg = gl.m_strErrorMsg;
				}
				//WriteLog(_T("SetIcon  Begin..."));
				if (tt.GetTime() - gl.m_nNewDataTime < 60)
				{
					m_btTLM.SetIcon(IDI_OPEN, NULL);
					gl.m_strNewMsg = _T("井数据查询...")+ tt.Format(_T("%H:%M:%S"));
				}
				else
					m_btTLM.SetIcon(IDI_CLOSE, NULL);
				if (gl.m_bOpenMaster)
					m_btMASTER.SetIcon(IDI_OPEN, NULL);
				else
					m_btMASTER.SetIcon(IDI_CLOSE, NULL);
				if (gl.m_bOpenYqhDB)
					m_btYQH.SetIcon(IDI_OPEN, NULL);
				else
					m_btYQH.SetIcon(IDI_CLOSE, NULL);
				if (tt.GetTime() - gl.m_nRedisDataTime < 60)
					m_btREDIS.SetIcon(IDI_OPEN, NULL);
				else
					m_btREDIS.SetIcon(IDI_CLOSE, NULL);
				if (gl.m_bOpenKdDB)
					m_btKD.SetIcon(IDI_OPEN, NULL);
				else
					m_btKD.SetIcon(IDI_CLOSE, NULL);
				//WriteLog(_T("SetIcon  End..."));
			}
			catch (...)
			{

			}
		}

		m_nTickCount++;
	}
	CFormView::OnTimer(nIDEvent);
}

void CRTOCDataInterfaceView::FillList(bool bInsert)
{
	if (bInsert)
		m_ctlList.DeleteAllItems();
	CString strTemp;
	int nRows = gl.tlm.m_aWells.GetCount();
	for (int i = 0; i < nRows; i++)
	{
		SINGLE_WELL sw = gl.tlm.m_aWells.GetAt(i);
		strTemp.Format(_T("%d"), i + 1);
		if (bInsert){
			m_ctlList.InsertItem(i, strTemp, 0);
		} else {
			m_ctlList.SetItemText(i, 0, strTemp);
		}
		m_ctlList.SetItemText(i, 1, sw.strWN);
		strTemp.Format(_T("%.2f"), sw.dCurDepth);
		m_ctlList.SetItemText(i, 2, strTemp);
		CTime tBegin = CTime(sw.nNewDataTime);
		m_ctlList.SetItemText(i, 3, tBegin.Format(_T("%Y-%m-%d %H:%M:%S")));
		if(sw.nToZxq==0){
			m_ctlList.SetItemText(i, 5, _T("关闭"));
		} else {
			if (sw.nZxqDataTime != sw.nNewDataTime)  {
				m_ctlList.SetItemText(i, 5, _T("同步,入库错误"));
			} else {
				m_ctlList.SetItemText(i, 5, _T("同步"));
			}
		}
		if (sw.nToYqh == 0) {
			m_ctlList.SetItemText(i, 6, _T("关闭"));
		} else {
			if (sw.nYqhDataTime != sw.nNewDataTime) {
				m_ctlList.SetItemText(i, 6, _T("同步,入库错误"));
			} else {
				m_ctlList.SetItemText(i, 6, _T("同步"));
			}
		}
		if (sw.nToYqhUrl == 0) {
			m_ctlList.SetItemText(i, 8, _T("关闭"));
		} else {
			if (sw.nYqhDataTimeUrl != sw.nNewDataTime) {
				m_ctlList.SetItemText(i, 8, _T("同步,api错误"));
			} else {
				m_ctlList.SetItemText(i, 8, _T("同步"));
			}
		}

		if (sw.nToKD == 0) {
			m_ctlList.SetItemText(i, 7, _T("关闭"));
		} else {
			if (sw.nKDDataTime != sw.nNewDataTime) {
				m_ctlList.SetItemText(i, 7, _T("同步,入库错误"));
			} else {
				m_ctlList.SetItemText(i, 7, _T("同步"));
			}
		}
		long t = CTime::GetCurrentTime().GetTime() - sw.nNewDataTime;
		if (t -sw.nTimeSpan < 60 && sw.m_stop  == false) {
			m_ctlList.SetItemText(i, 4, _T("正常"));
		} else {
			if (t - sw.nTimeSpan > 120) {

				sw.nNewDataTime = CTime::GetCurrentTime().GetTime();;
				sw.m_stop = true;

				::EnterCriticalSection(&m_cWS);
				gl.tlm.m_aWells.SetAt(i, sw);
				::LeaveCriticalSection(&m_cWS);
				m_ctlList.SetItemText(i, 4, _T("**重启线程**"));
			}
			else{
				m_ctlList.SetItemText(i, 4, _T("**中断**"));
			}

		}
	}
}

void CRTOCDataInterfaceView::OnNMCustomdrawList1(NMHDR *pNMHDR, LRESULT *pResult)
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	switch (pLVCD->nmcd.dwDrawStage)
	{
	case CDDS_PREPAINT:
		*pResult = CDRF_NOTIFYITEMDRAW;
		return;
	case CDDS_ITEMPREPAINT:
		*pResult = CDRF_NOTIFYSUBITEMDRAW;
		return;
	case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
	{
		COLORREF crText, crBkgnd;
		int row = pLVCD->nmcd.dwItemSpec;//行
		int col = pLVCD->iSubItem;//列
		if (col == 6 || col == 5 || col == 7 || col== 8)
		{
			SINGLE_WELL* sw1 = &gl.tlm.m_aWells.GetAt(row);
			if ((sw1->nToZxq==1 && col==5) || (sw1->nToYqh==1 && col==6) || (sw1->nToKD == 1 && col == 7) || (sw1->nToYqhUrl == 1 && col == 8))
			{
				crText = RGB(0, 0, 0);
				crBkgnd = RGB(0, 255, 0);
			}
			else
			{
				crText = RGB(0, 0, 0);
				crBkgnd = RGB(255, 0, 0);
			}
			pLVCD->clrText = crText;
			pLVCD->clrTextBk = crBkgnd;
		}
	}
	break;
	}
	*pResult = 0;
}
